#include<bits/stdc++.h>

using namespace std;

struct student
{
	int a[10];
}st[1010];
int m[10];
int f;
int main()
{
	int t,n;
	int s;
	cin>>t;
	while(t--)
	{
		memset(m,0,sizeof(m));
		cin>>n;
		for(int i = 1; i <= n; i++)
		{
			for(int j = 1; j <= 5; j++)
			{
				cin>>st[i].a[j];
				if(st[i].a[j] == 1)
				{
					m[j] += 1;
				}
			}
		}
		for(int i = 1; i <= 5; i++)
		{
			s = 0;
			f = 0;
			if(m[i] >= n/2)
			{
				for(int  j = i + 1; j <= 5; j++)
				{
					s = 0;
					f = 0;
					if(m[j] >= n/2)
					{
						for(int k = 1; k <= n; k++)
						{
							if(st[k].a[i] == 1 || st[k].a[j] == 1)
							{
								s++;
							}
						}
						if(s == n)
						{
							f = 1;
							cout<<"YES"<<endl;
							break;
						}
					}
					if(f == 1)
					{
						break;
					}
				}
			}
			if(f == 1)
			{
				break;
			}
		}
		if(f == 0)
		{
			cout<<"NO"<<endl;
		}
	}
	return 0;
}
